﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TCPClient.UI.LogicForUserControls;

namespace TCPClient.UI
{
    public partial class SettingsForm : Form
    {
        public SettingsForm()
        {
            InitializeComponent();
            setDefaultValuesFromServer();
        }

        private void setDefaultValuesFromServer()
        {
            ScMainUserControlLogicManager.Instance.setLenghtOfAShift();
            numericUpDownLengthOfShift.Value = Convert.ToDecimal(DefaultConfigurationHandler.Instance.LenghtOfShift);
            ScMainUserControlLogicManager.Instance.setNumberOfShiftsPerDay();
            numericUpDownNumberOfShiftsPerDay.Value =
                Convert.ToDecimal(DefaultConfigurationHandler.Instance.NumberOfShiftsPerDay);
            ScMainUserControlLogicManager.Instance.setStartingHourOfWork();
            numericUpDownWorkingStartTimeHour.Value =
                Convert.ToDecimal(DefaultConfigurationHandler.Instance.StartingTimeOfWork);
            numericUpDownNumberOfWorkresInShift.Value =
                Convert.ToDecimal(ScMainUserControlLogicManager.Instance.GetNumnerOfWorkersInShift());

        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            ScMainUserControlLogicManager.Instance.ChangeNumberOfShiftsPerDay(numericUpDownNumberOfShiftsPerDay.Value.ToString());
            ScMainUserControlLogicManager.Instance.ChangeLenghtOfShift(numericUpDownLengthOfShift.Value.ToString());
            ScMainUserControlLogicManager.Instance.ChangeStartTimeOfWork(numericUpDownWorkingStartTimeHour.Value.ToString());
            ScMainUserControlLogicManager.Instance.ChangeNumnerOfWorkersInShift(numericUpDownNumberOfWorkresInShift.Value.ToString()); 
            ScMainUserControlLogicManager.Instance.setLenghtOfAShift();
            ScMainUserControlLogicManager.Instance.setNumberOfShiftsPerDay();
            ScMainUserControlLogicManager.Instance.setStartingHourOfWork();
            this.Close();
        }


    }
}
